<template>
  <CommonCard title="累计订单额" :value="reportData.orderToday">
    <template #default>
      <v-chart :option="option"></v-chart>
    </template>
    <template #footer>
      <span>昨日销售额</span>
      <span class="css-1">¥ {{ reportData.orderLastDay }}</span>
    </template>
  </CommonCard>
</template>

<script setup>
import { ref, watch } from 'vue';

import CommonCard from './CommonCard.vue';

const props = defineProps({
  reportData: {
    type: Object,
    default: () => ({}),
    required: true,
  },
});

const option = ref({});

const rederChart = data => {
  option.value = {
    xAxis: {
      type: 'category',
      boundaryGap: false,
      show: false,
    },
    yAxis: {
      type: 'value',
      show: false,
    },
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
    },
    series: [
      {
        data: data,
        type: 'line',
        areaStyle: {
          color: 'purple',
        },
        //隐藏拐点
        itemStyle: {
          opacity: 0,
        },
        //设置线条样式
        lineStyle: {
          opacity: 0,
        },
        //平滑
        smooth: true,
      },
    ],
  };
};

watch(props, () => {
  rederChart(props.reportData.orderTrend);
});
</script>

<style scoped></style>
